package DAO;

import Interfaces.ISignUp_Dao;
import Models.SignUp;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SignUp_Dao implements ISignUp_Dao {

    @Override
    public SignUp makeRegister(String Name, String LastName, String Phone, String Email, String Username, String Password, String Repass) throws IllegalArgumentException {

        Connection conn = null;
        PreparedStatement pst = null;
        try {
            conn = javaconnect.connectDB();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(SignUp_Dao.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            String query = "INSERT INTO signuptable (name , lastname , phone , email , username , password , repass) value (?,?,?,?,?,?,?)";
            pst = conn.prepareStatement(query);
            pst.setString(1, Name);
            pst.setString(2, LastName);
            pst.setString(3, Phone);
            pst.setString(4, Email);
            pst.setString(5, Username);
            pst.setString(6, Password);
            pst.setString(7, Repass);
            pst.execute();
            pst.close();
            conn.close();
            
        } catch (SQLException e) {
            throw new IllegalArgumentException("Error in SignUp_Dao");
        }
        return null;
    }
}
